package runninbuddy;

import net.rim.device.api.gps.BlackBerryLocation;
import net.rim.device.api.system.AccelerometerData;

public class RunnerData {
	public final BlackBerryLocation bbLocation;

	public final AccelerometerData accData;

	public RunnerData(BlackBerryLocation bbLocation, AccelerometerData accData) {
		this.bbLocation = bbLocation;
		this.accData = accData;
	}

	public boolean isValid() {
		return bbLocation != null && bbLocation.isValid() && accData != null;
	}

	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!(obj instanceof RunnerData))
			return false;
		RunnerData that = (RunnerData) obj;
		return (this.bbLocation == null ? that.bbLocation == null
				: this.bbLocation.equals(that.bbLocation))
				&& this.accData == null ? that.accData == null : this.accData
				.equals(that.accData);
	}

	public int hashCode() {
		final int prime = 37;
		int result = 23;
		if (bbLocation == null)
			result *= prime;
		else
			result *= prime * bbLocation.hashCode();
		if (accData == null)
			result *= prime;
		else
			result *= prime * accData.hashCode();
		return result;
	}

}
